/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.thompv.BaitapMuc1_2;
import java.util.Scanner;
/**
 *
 * @author SONY
 */
public class Bai8Muc1 {
    static boolean nt(int n)
    {
        if(n<2) return false;
        for(int i=2;i<=(int)Math.sqrt(n);i++)
            if(n%i==0) return  false;
        return true;
    }
    static boolean chuso(int n)
    {
        while(n>0)
        {
            if(!nt(n%10)) return false;
            n/=10;
        }
        return true;
    }
    static boolean kogiam(int n)
    {
        while(n>1)
        {
            if(n%10<(n/10)%10) return false;
            n/=10;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("Ket qua:");
        for(int i=1000000;i<=9999999;i++)
            if(chuso(i)&&kogiam(i)&&nt(i)) System.out.println(i);
    }
}
